﻿using System.Text.RegularExpressions;

namespace Bilibili.Model.User
{
    public sealed class MessageReply
    {
        public int code { get; set; }
        public object data { get; set; }
        public string message { get; set; }
        public string id { get; set; }
        public string cursor { get; set; }
        public string title { get; set; }
        public string Title
        {
            get
            {
                Match ban = Regex.Match(title, @"#{(.*?)}{""(.*?)""}");
                if (ban.Groups[1].Value.Length == 0)
                    return title;
                else
                {
                    link = ban.Groups[2].Value;
                    return ban.Groups[1].Value + title.Replace(ban.Groups[0].Value, string.Empty);
                }
            }
        }
        public string link { get; set; }
        public string content { get; set; }
        public string Content
        {
            get
            {
                string ban = Regex.Match(content, @"^#{(.*?)}{""(.*?)""}$").Groups[1].Value;
                if (ban.Length == 0)
                    return content;
                else
                {
                    if (link == null)
                        link = Regex.Match(content, @"^#{(.*?)}{""(.*?)""}$").Groups[2].Value;
                    return ban;
                }
            }
        }
        public string Content_Notiy
        {
            get
            {
                Match ban = Regex.Match(content, @"#{(.*?)}{""(.*?)""}");
                if (ban.Groups[1].Value.Length == 0)
                    return content;
                else
                {
                    link = ban.Groups[2].Value;
                    return content.Replace(ban.Groups[0].Value, ban.Groups[1].Value);
                }
            }
        }
        public object publisher { get; set; }
        public string name { get; set; }
        public string face { get; set; }
        public string mid { get; set; }
        public string time_at { get; set; }
    }
}